# Maintainer: Christian Rebischke <chris.rebischke@archlinux.org>
# Contributor: navigaid <navigaid@gmail.com>
pkgname=yaegi
pkgver=0.14.3
pkgrel=1
pkgdesc='Yet another Elegant Go Interpreter'
arch=('loong64' 'x86_64')
url='https://github.com/containous/yaegi'
license=('Apache')
makedepends=('go')
depends=('glibc')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/containous/yaegi/archive/v${pkgver}.tar.gz")
sha512sums=('956aced162a47cb155f0d8c6bb47f6e16cc6e01f7537b2025363807b080290fff07ee93f5d23834ad63f223656e56e7e24f7e0cdb02d3dfeb7e664bff6f258b4')

build() {
  cd "${pkgname}-${pkgver}"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-trimpath -mod=readonly -modcacherw -ldflags=-linkmode=external"
  go build -v ./cmd/yaegi
}

# disabling tests...
#check() {
#  cd "${pkgname}-${pkgver}"
#  sed -i 's|"-race", ||' ./cmd/yaegi/yaegi_test.go
#  GOROOT="/usr/lib/go" go test -v ./...
#}

package() {
  cd "${pkgname}-${pkgver}"
  install -Dm755 yaegi "${pkgdir}/usr/bin/${pkgname}"
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
